<template>
  <div :class="['api-card', 'api-card-' + type]" @click="handleClick">
    <div class="img-box card-img">
      <img src="https://cdn.wapi.cn/upload/1d/ca/ca447614e09d5e6d07c8b33e3cd89405.png?v=20240226" alt="">
    </div>
    <div class="more-button" :style="{display: type === 'tool' ? 'none' : 'block'}">
      <el-dropdown trigger="hover" placement="bottom" @command="handleCommand">
        <div class="button-icon" />
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            v-for="item in cardData.subApi"
            :key="item.code"
            :command="item"
          >
            {{ item.name }}
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <div class="content">
      <h4 class="title">身份证二要素实名认证</h4>
      <p class="sub-title">输入姓名和身份证号，通过官方权威核查，实时校验此二要素是否一致，同时返回生日、性别、籍贯等信息官方权威渠道， 精准核验，校验100%可靠;高准确率-实时查询零缓存，毫秒级响应， 准确率99.99%;专业服务-7*24小时服务，极速响应，为用户保驾护航; 支持批量核验功能为保护个人信息，相同姓名或者号码不允许频繁核验
      </p>
      <p class="price">￥0.3元/次</p>
    </div>
    <div class="arrow" />
  </div>
</template>

<script>
export default {
  name: 'ApiCard',
  components: {},
  mixins: [],
  props: {
    type: {
      type: String,
      default: ''
    },
    cardData: {
      type: Object,
      default() {
        return {
          apiName: '',
          apiDesc: '',
          price: '0.5',
          subApi: [
            {
              name: '身份证二要素实名认证',
              code: '10'
            },
            {
              name: '身份证八要素实名认证',
              code: '20'
            }
          ]
        }
      }
    }
  },
  data() {
    return {}
  },
  computed: {},
  watch: {},
  created() {
  },
  mounted() {
  },
  methods: {
    handleClick() {
      this.$emit('handle-click', this.cardData)
    },
    handleCommand(data) {
      console.log(data, 'handleCommand')
      this.$emit('handle-sub-click', data)
    }
  }
}
</script>

<style scoped lang="scss">
@import "../../element-variables.scss";

.api-card {
  background: #fff;
  width: 100%;
  padding: 20px 10px;
  position: relative;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  cursor: pointer;
  &.api-card-tool {
    display: flex;
    flex-direction: row;
    .content {
      flex: 1;
      margin-left: 10px;
      h4.title {
        text-align: left;
      }
    }
  }
  .arrow {
    position: absolute;
    right: 10px;
    bottom: 20px;
    width: 28px;
    height: 14px;
    background: url("../../assets/images/api-card-arrow.png") no-repeat center;
    background-size: 100%;
    display: none;
  }
  .more-button {
    position: absolute;
    right: 10px;
    top: 10px;
    .button-icon {
      background: url("../../assets/images/more_grays.png") no-repeat center;
      background-size: 100%;
      width: 18px;
      height: 18px;
    }
  }
  .card-img {
    margin: 0 auto;
    width: 60px;
    height: 65px;
    img {
      transition: all 1s;
    }
  }
  h4.title {
    text-align: center;
    margin: 15px 0 18px;
    font-weight: bold;
    font-size: 16px;
    color: #333;
  }
  p.sub-title {
    color: #999;
    font-size: 14px;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    line-height: 1.6;
  }
  p.price {
    font-size: 16px;
    color: #f63;
    font-weight: bold;
    margin: 20px 0 0;
    &.free {
      color: $--color-primary;
    }
  }
  &:hover {
    z-index: 2;
    -webkit-box-shadow: 0 5px 20px rgba(77, 185, 202,.3);
    -moz-box-shadow: 0 5px 20px rgba(77, 185, 202,.3);
    -o-box-shadow: 0 5px 20px rgba(77, 185, 202,.3);
    box-shadow: 0 5px 20px rgba(77, 185, 202,.3);
    transform: translate3d(0, -2px, 0);
    -webkit-transform: translate3d(0, -2px, 0);
    .card-img {
      //transform: rotate(360deg);
      img {
        transform: rotate(360deg);
      }
    }
    h4.title {
      color: #f60;
    }
    .arrow {
      display: block;
    }
  }
}
</style>
